<?php
 $id=(isset($_GET['id']))?$_GET['id']:0;
 require 'lj.php';
 if (empty($_POST)) {
    $sql="select * from tb_emp where e_id={$id}";
    $result=$db->query($sql);
    $l=$result->fetch_array();
   include 'xg_html.php';
 } else {
     $e_name=$_REQUEST['e_name'];
     $e_dept=$_REQUEST['e_dept'];
     $e_img=$_REQUEST['e_img'];
     $date_of_birth=$_REQUEST['date_of_birth'];
     $date_of_entry=$_REQUEST['date_of_entry'];
     $sql="update tb_emp set e_name='{$e_name}',e_dept='{$e_dept}',e_img='{$e_img}',date_of_birth='{$date_of_birth}',date_of_entry='{$date_of_entry}' where e_id={$id}";
     $rs=$db->query($sql);
     if ($rs==true)      //根据返回结果，做不同的响应
       {   
           header("Location:index.php");//直接跳转
       }
       else
       {
           // JavaScript弹出对话框跳转

           echo "<script language='javascript'>";

           echo "alert('修改失败！');";
           echo "window.location.href='index.php';";
           echo "</script>";
       }      
}
 $db->close();